package com.ddd.infrastructure.repository;

import com.ddd.domain.operationLog.model.OperationLogEntity;
import com.ddd.domain.operationLog.repository.OperationLogRepository;
import com.ddd.infrastructure.convertor.OperationLogConvertor;
import com.ddd.infrastructure.repository.database.dataobject.OperationLogDo;
import com.ddd.infrastructure.repository.database.mapper.OperationLogMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * OperationLog Repository Impl
 *
 * @author guowm
 */
@Component
@RequiredArgsConstructor
public class OperationLogGatewayImpl implements OperationLogRepository {

    private final OperationLogMapper operationLogMapper;

    @Override
    @Async
    public void save(OperationLogEntity operationLogEntity) {
        OperationLogDo operationLogDo = OperationLogConvertor.toAddOperationLogDo(operationLogEntity);
        operationLogMapper.insert(operationLogDo);
    }
}
